var http = require('http'),
	url = require('url'),
	person = require('./person'),
	note = require('./note');

http.createServer(function (request, response) {
	var rq_url_json = url.parse(request.url,true),
		rq_params = rq_url_json["query"],
		rq_method = request.method,
		rpson = "";
	if(rq_url_json.pathname == '/find'){
		person.get({'full_name' : rq_params["full_name"]},{cb : function(err,res){
			if(err){
				rpson = "code:-1,msg:'err'";
				console.log("find err!");
			}else{
				console.log(res);
				rpson = ('"code":0,"msg":"suc","data":'+JSON.stringify(res));
				console.log("find succ!")
			}
			response.writeHead(200, {'Content-Type': 'application/x-javascript','Access-Control-Allow-Origin':'*'});
			response.end('{'+rpson+'}');
		}})
	}
}).listen(9999);